<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::get('/', array('as' =>'/' , 'uses'=>'HomeController@index'));

Route::get('/admin', array('as' =>'/admin', 'uses'=>'AdminController@login'));

Route::get('/admin/adminpanel', array('as' =>'/admin/adminpanel', 'uses'=>'AdminController@adminPanel'));

Route::get('users', array('as'=>'users', 'uses'=>'UsersController@index'));

Route::get('user/{id}', array('as'=>'user', 'uses'=>'UsersController@user'));

Route::get('kategorije/{kategorija}', array('as'=>'kategorije', 'uses' => 'PostsController@postovi'));

Route::get('admin/vesti/nova', 'PostsController@unosVesti');

Route::get('admin/baner/nova', 'PostsController@unosBanera');

Route::get('admin/promo/nova', 'PostsController@unosPromo');

Route::get('admin/korisnici/korisnici', 'UsersController@korisnici');

Route::post('/vesti/snimiVest', 'PostsController@snimiVest');

Route::get('vesti/izmena/{id}', array('as'=>'vest', 'uses'=>'PostsController@getVestForEdit'));

Route::get('/vesti/kategorije', 'PostsController@kategorije');

Route::get('/post/{id}', 'PostsController@getPost');

Route::post('admin/login', 'LoginController@loginAdmin');
Route::post('korisnik/login', 'LoginController@loginUser');

Route::get('test', function(){

	/*$k=new Korisnik;

	$k->username='xxx'; $k->password='xxx';
	$k->save();

	$a=new Autor;

	$a->opis='xxxx';

	$a->korisnik()->associate($k);

	$a->save();


	//return Response::json($postovi);*/

	$korisnik = 
		Korisnik::with('Autor')->where('username','=', 'xxx')->get();
		

	return Response::json($korisnik);

}


	);

Route::get('loginTest', function()
{
    $userdata = array(
        'username' => 'vpetrovic',
        'password' => 'test'
    );

    /* Try to authenticate the credentials */
    if(Auth::attempt($userdata))
    {
        print_r(Auth::user());

        return 'Uspešan login';
    }
    else
    {
        return 'Neuspešan login';
    }
});
